package com.mchat.web.config;

import com.mchat.communication.server.ChatServer;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;

import javax.annotation.Resource;

@Configuration
public class NettyServerConfig implements ApplicationListener<ContextRefreshedEvent> {
    @Resource
    private ChatServer chatServer;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        System.err.println("nettyListener Startup!");
        new Thread(() -> chatServer.start()).start();
        System.err.println("nettyListener end!");
    }

}